package com.guiassysdesigners.webapp.action;

import com.guiassysdesigners.dao.SearchException;
import com.guiassysdesigners.model.Suggestion;
import com.guiassysdesigners.service.SuggestionManager;
import java.io.Serializable;
import java.util.List;

public class SuggestionList extends BasePage implements Serializable {

	private static final long serialVersionUID = 972359310602744018L;

	private String query;
	private SuggestionManager suggestionManager;

	public void setQuery(String query) {
		this.query = query;
	}

	public String getQuery() {
		return query;
	}

	public SuggestionList() {
		setSortColumn("title");
	}

	public List<Suggestion> getSuggestions() {
		try {
			return sort(suggestionManager.search(query));
		} catch (SearchException se) {
			addError(se.getMessage());
			return sort(suggestionManager.search(query));
		}
	}

	public String search() {
		return "suggestionList";
	}

	public void setSuggestionManager(SuggestionManager suggestionManager) {
		this.suggestionManager = suggestionManager;
	}

}
